package net.cellkyborg.server;

import net.cellkyborg.RSInstances.*;

public class ButtonHandler {

	private RSPlayer myPlayer;
	private Player thisPlayer;

	public ButtonHandler(Player p) {
		thisPlayer = p;
	}

	public ButtonHandler(RSPlayer p) {
		myPlayer = p;
	}

	public void buttonPressed(int interID, int buttID) {
		switch (interID) {
		// case
		case 92:
			interface92(buttID);
			break;
		case 182:
			interface182(buttID);
			break;
		case 192:
			interface192(buttID);
			break;
		case 239:
			interface239(buttID);
			break;
		case 274: 
			interface274(buttID);
			break;
		case 259: 
			interface259(buttID);
			break;
		case 261:
			interface261(buttID);
			break;
		case 387: 
			interface387(buttID);
			break;
		case 464:
			interface464(buttID);
			break;
		case 548:
			interface548(buttID);
			break;
		case 589:
			interface589(buttID);
			break;
		default:	
			System.out.println("buttonPressed (interID = "+interID+", buttID = "+buttID+")");
			break;
		}
	}

	private void interface589(int ID){
		switch(ID) {
			case 9://clan setup
				myPlayer.setInterface(0, 590, 77);
				break;
		}
	}
	
	private void interface548(int ID){
	}
	
	private void interface92(int ID) {
		switch(ID) {
		case 24: //autoretaliate switch
			switch (myPlayer.playerEquipment[myPlayer.playerWeapon]) {
				case 11694:
					myPlayer.doAnimation(7074, 0);
					myPlayer.doGraphics(1222, 0, 0);
					break;
				case 11696:
					myPlayer.doAnimation(7073, 0);
					myPlayer.doGraphics(1223, 0, 0);
					break;
				case 11698:
					myPlayer.doAnimation(7071, 0);
					myPlayer.doGraphics(1220, 0, 0);
					break;
				case 11700:
					myPlayer.doAnimation(7070, 0);
					myPlayer.doGraphics(1221, 0, 0);
					break;			
			}
			break;
		}
	}
	
	private void interface182(int ID) { // Logout
		SQLHandler.saveCharacter(myPlayer);
		myPlayer.destroy();
	}
	
	private void interface192(int ID) {
		switch(ID) {
			case 3: //enchant c'bow bolts
				myPlayer.setInterface(0, 432, 77);
				break;
		}
	}

	private void interface239(int ID) {
	}

	private void interface261(int ID) {
		switch (ID) {
		case 0: // Running On/Off
			if (myPlayer.isRunning) {
				myPlayer.isRunning = false;
			} else if (myPlayer.playerEnergy > 0) {
				myPlayer.isRunning = true;
			}
			myPlayer.setConfig(173, (myPlayer.isRunning) ? 1 : 0);
			break;
		case 5: // Player Owned Home Settinga
			myPlayer.setInterface(1, 398, 110);
			myPlayer.hasHouseOptionsOpen = true;
			break;
		}
	}
	
	private void interface274(int ID) {
		switch (ID) {               
		case 11:	
			myPlayer.setInterface(1, 259, 101);
			break;		
		}
	}
	
	private void interface259(int ID) {
		switch (ID) {               
		case 10:	
			myPlayer.setInterface(1, 274, 101);
			break;		
		}
	}
	
	private void interface387(int ID) {
		switch (ID) {
			case 50: // Show Items Kept At Death
				myPlayer.setInterface(0, 102, 77);
				break;
			case 51: // Show Equipment / Bonuses
				myPlayer.setInterface(0, 465, 77);
				break;
		}
	}
	
	//Emote List
	public void interface464(int ID) {
        switch (ID) {
            case 2:
                myPlayer.doAnimation(855, 0); 
                break;
            case 3:
                myPlayer.doAnimation(856, 0);
                break;
            case 4:
                myPlayer.doAnimation(858, 0);
                break;
            case 5:
                myPlayer.doAnimation(859, 0);
                break;
            case 6:
                myPlayer.doAnimation(857, 0);
                break;
            case 7:
                myPlayer.doAnimation(863, 0);
                break;
            case 8:
                myPlayer.doAnimation(2113, 0);
                break;
            case 9:
                myPlayer.doAnimation(862, 0);
                break;
            case 10:
                myPlayer.doAnimation(864, 0);
                break;
            case 11:
                myPlayer.doAnimation(861, 0);
                break;
            case 12:
                myPlayer.doAnimation(2109, 0);
                break;
            case 13:
                myPlayer.doAnimation(2111, 0);
                break;
            case 14:
                myPlayer.doAnimation(866, 0);
                break;
            case 15:
                myPlayer.doAnimation(2106, 0);
                break;
            case 16:
                myPlayer.doAnimation(2107, 0);
                break;
            case 17:
                myPlayer.doAnimation(2108, 0);
                break;
            case 18:
                myPlayer.doAnimation(860, 0);
                break;
            case 19:
                myPlayer.doAnimation(0x558, 0);
                break;
            case 20:
                myPlayer.doAnimation(2105, 0);
                break;
            case 21:
                myPlayer.doAnimation(2110, 0);
                break;
            case 22:
                myPlayer.doAnimation(865, 0);
                break;
            case 23:
                myPlayer.doAnimation(2112, 0);
                break;
            case 24:
                myPlayer.doAnimation(0x84F, 0);
                break;
            case 25:
                myPlayer.doAnimation(0x850, 0);
                break;
            case 26:
                myPlayer.doAnimation(1131, 0);
                break;
            case 27:
                myPlayer.doAnimation(1130, 0);
                break;
            case 28:
                myPlayer.doAnimation(1129, 0);
                break;
            case 29:
                myPlayer.doAnimation(1128, 0);
                break;
            case 30:
                myPlayer.doAnimation(4275, 0);
                break;
            case 31:
                myPlayer.doAnimation(4278, 0);
                myPlayer.doGraphics(713, 0, 0);
                break;
            case 32:
                myPlayer.doAnimation(4280, 0);
                break;
            case 33:
                myPlayer.doAnimation(4276, 0);
                myPlayer.doGraphics(712, 0, 0);
                break;
            case 34:
                myPlayer.doAnimation(3544, 0);
                break;
            case 35:
                myPlayer.doAnimation(3543, 0);
                break;
            case 36:
                myPlayer.doAnimation(7272, 0);
                myPlayer.doGraphics(1244, 0, 0);
                break;
            case 37:
                myPlayer.doAnimation(2836, 0);
                break;
            case 38:
                myPlayer.doAnimation(6111, 0);
                break;
            case 39:
				int cape[] = {9747,9750,9753,9756,9759,9762,9765,9768,9771,9774,9777,9780,9783,9786,9789,9792,9795,9798,9801,9804,9807,9810,9948,10662};
				int capeT[] = {9748,9751,9754,9757,9760,9763,9766,9769,9772,9775,9778,9781,9784,9787,9790,9793,9796,9799,9802,9805,9808,9811,9949};
				int capeA[] = {4959,4981,4961,4973,4979,4939,4947,4971,4977,4969,4965,4949,4937,4967,4953,4941,4943,4951,4955,4975,4957,4963,5158,4945};
				int capeG[] = {823,828,824,832,829,813,817,833,830,835,826,818,812,827,820,814,815,819,821,831,822,825,907,816};
				if (myPlayer.playerEquipment[myPlayer.playerCape] == cape[myPlayer.getSkillcapeID()]	
				||	myPlayer.playerEquipment[myPlayer.playerCape] == capeT[myPlayer.getSkillcapeID()])	{
					myPlayer.doAnimation(capeA[myPlayer.getSkillcapeID()], 0);						
					myPlayer.doGraphics(capeG[myPlayer.getSkillcapeID()], 0, 0);						
				}						
				break;
		}
	}
	
	
}